import { useState } from "react";

function cancel(){
    let currentAbortController = null;
    let [list,setList]=useState([])
    function fetchData(query) {
      // 取消上一次未完成的请求
      if (currentAbortController) {
        currentAbortController.abort();
      }
    
      // 创建新的 AbortController
      currentAbortController = new AbortController();
    
      return fetch(`http://127.0.0.1:7001/q=${query}`, {
        signal: currentAbortController.signal
      })
      .then(response => response.json())
      .then(data => {
        // 处理请求成功的数据
        setList(data);
      })
    }
    
}
